<div class="modal fade " id="addExchangeInfoModal"   role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document" style="width: 50%">
        <div class="box box-info">
            <div class="box-header with-border">
                <h3 class="box-title">交换模板配置</h3>
            </div>
            <!-- /.box-header -->
            <!-- form start -->
            <form class="form-horizontal" id="addExchangeInfoForm">
                <div class="box-body">
                    <div class="form-group">
                        <label for="inputEmail3" class="col-sm-2 control-label">名称</label>
                        <div class="col-sm-7">
                            <input id="addExchangeInfoModal_name" type="text" class="form-control">
                            <input id="addExchangeInfoModal_id" type="hidden" >
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="inputEmail3" class="col-sm-2 control-label">校验脚本</label>
                        <div class="col-sm-7">
                            <textarea id="addExchangeInfoModal_beforeContent" class="form-control" rows="4" placeholder="验证执行的可行性">
                                 </textarea>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="inputEmail3" class="col-sm-2 control-label">内容脚本</label>
                        <div class="col-sm-7">
                            <textarea id="addExchangeInfoModal_content" class="form-control" rows="8"  placeholder="执行脚本">
                                 </textarea>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="inputEmail3" class="col-sm-2 control-label">说明</label>
                        <div class="col-sm-7">
                            <textarea id="addExchangeInfoModal_remark" class="form-control" rows="3"  placeholder="说明">
                                 </textarea>
                        </div>
                    </div>
                </div>
                <!-- /.box-body -->
                <div class="box-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal"  >取消</button>

                    <button type="button" class="btn btn-primary pull-right" onclick="addExchangeInfoModal_save()">保存</button>
                </div>
                <!-- /.box-footer -->
            </form>
        </div>
    </div>
</div>
<script>
    function addExchangeInfoModalInit() {
        $("#addExchangeInfoModal_name").val("");
        $("#addExchangeInfoModal_id").val("");
        $("#addExchangeInfoModal_beforeContent").val("");
        $("#addExchangeInfoModal_content").val("");
        $("#addExchangeInfoModal_remark").val("");
    }
    function addExchangeInfoModalSetValue(index) {
        var data = $("#table1").bootstrapTable("getData")[index] ;
        $("#addExchangeInfoModal_name").val(data.name);
        $("#addExchangeInfoModal_id").val(data.id);
        $("#addExchangeInfoModal_beforeContent").val(data.beforeContent);
        $("#addExchangeInfoModal_content").val(data.content);
        $("#addExchangeInfoModal_remark").val(data.remark);
    }
    function addExchangeInfoModal_save() {
        var data = {
            id:$("#addExchangeInfoModal_id").val(),
            name:$("#addExchangeInfoModal_name").val(),
            beforeContent:$("#addExchangeInfoModal_beforeContent").val(),
            content:$("#addExchangeInfoModal_content").val(),
            remark:$("#addExchangeInfoModal_remark").val()
        };
        var url = "/exchangeinfo/save" ;
        postReq(url,data,function(result){
            if (result.success) {
                toastr['success']('操作成功', '提示');
                $("#table1").bootstrapTable("refresh");
                $("#addExchangeInfoModal").modal("hide");
            } else {
                toastr['error'](result.msg, '提示');
            }
        }) ;
    }
</script>